﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using InfoStuffStore.Common;

namespace InfoStuffStore
{
    public partial class FormVisitors : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["admin"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            if (!IsPostBack)
            {
                GetVisitors();
            }
        }

        private void GetVisitors()
        {
            using (DBDataContext dataContext = new DBDataContext())
            {
                GridVisitors.DataSource = dataContext.Visitors.OrderByDescending(obj => (obj.VisitID)).Take(50);
                GridVisitors.DataBind();
            }
        }
    }
}